﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using lcmyjobs.Model;
namespace lcmyjobs.BLL
{
	/// <summary>
	/// enterprise_reward
	/// </summary>
	public partial class enterprise_reward
	{
		private readonly lcmyjobs.DAL.enterprise_reward dal=new lcmyjobs.DAL.enterprise_reward();
		public enterprise_reward()
		{}
         /// <summary>
        /// 批量个更改
        /// </summary>
        /// <param name="keywords">关键字</param>
        /// <param name="value">更改值</param>
        /// <param name="where">更改条件enterprise_rid</param>
        /// <returns></returns>
        public bool UpdateWhere(string keywords, string value, string where)
        {
            return dal.UpdateWhere(keywords, value, where);
        }
         /// <summary>
        /// 分页获取悬赏职位信息列表
        /// </summary>
        /// <param name="enterprise_bid">企业ID</param>
        /// <param name="currentPageIndex">当前页</param>
        /// <param name="pageSize">每页显示条目数</param>
        /// <param name="count">总条目数</param>
        /// <returns>返回的DataSet第2个表是企业名称</returns>
        public DataSet GetReward(int enterprise_bid, int currentPageIndex, int pageSize, out int count)
        {
            return dal.GetReward(enterprise_bid,currentPageIndex,pageSize,out count);
        }
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int enterprise_reward_id)
		{
			return dal.Exists(enterprise_reward_id);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(lcmyjobs.Model.enterprise_reward model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(lcmyjobs.Model.enterprise_reward model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int enterprise_reward_id)
		{
			
			return dal.Delete(enterprise_reward_id);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string enterprise_reward_idlist )
		{
			return dal.DeleteList(enterprise_reward_idlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public lcmyjobs.Model.enterprise_reward GetModel(int enterprise_reward_id)
		{
			
			return dal.GetModel(enterprise_reward_id);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public lcmyjobs.Model.enterprise_reward GetModelByCache(int enterprise_reward_id)
		{
			
			string CacheKey = "enterprise_rewardModel-" + enterprise_reward_id;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(enterprise_reward_id);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (lcmyjobs.Model.enterprise_reward)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.enterprise_reward> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<lcmyjobs.Model.enterprise_reward> DataTableToList(DataTable dt)
		{
			List<lcmyjobs.Model.enterprise_reward> modelList = new List<lcmyjobs.Model.enterprise_reward>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				lcmyjobs.Model.enterprise_reward model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new lcmyjobs.Model.enterprise_reward();
					if(dt.Rows[n]["enterprise_reward_id"]!=null && dt.Rows[n]["enterprise_reward_id"].ToString()!="")
					{
						model.enterprise_reward_id=int.Parse(dt.Rows[n]["enterprise_reward_id"].ToString());
					}
					if(dt.Rows[n]["enterprise_rid"]!=null && dt.Rows[n]["enterprise_rid"].ToString()!="")
					{
						model.enterprise_rid=int.Parse(dt.Rows[n]["enterprise_rid"].ToString());
					}
					if(dt.Rows[n]["enterprise_bh"]!=null && dt.Rows[n]["enterprise_bh"].ToString()!="")
					{
					model.enterprise_bh=dt.Rows[n]["enterprise_bh"].ToString();
					}
					if(dt.Rows[n]["price"]!=null && dt.Rows[n]["price"].ToString()!="")
					{
						model.price=decimal.Parse(dt.Rows[n]["price"].ToString());
					}
					if(dt.Rows[n]["releasetime"]!=null && dt.Rows[n]["releasetime"].ToString()!="")
					{
						model.releasetime=DateTime.Parse(dt.Rows[n]["releasetime"].ToString());
					}
					if(dt.Rows[n]["rtime"]!=null && dt.Rows[n]["rtime"].ToString()!="")
					{
						model.rtime=int.Parse(dt.Rows[n]["rtime"].ToString());
					}
					if(dt.Rows[n]["issuccess"]!=null && dt.Rows[n]["issuccess"].ToString()!="")
					{
						if((dt.Rows[n]["issuccess"].ToString()=="1")||(dt.Rows[n]["issuccess"].ToString().ToLower()=="true"))
						{
						model.issuccess=true;
						}
						else
						{
							model.issuccess=false;
						}
					}
					if(dt.Rows[n]["status"]!=null && dt.Rows[n]["status"].ToString()!="")
					{
						model.status=int.Parse(dt.Rows[n]["status"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

